<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1, user-scalable=no">
		<title>订单详情</title>
		<link rel="stylesheet" type="text/css" media="screen" href="{$staticHost}/static/css/base.css" />
		<link rel="stylesheet" type="text/css" media="screen" href="{$staticHost}/static/css/mod.css" />
		<link rel="stylesheet" type="text/css" media="screen" href="{$staticHost}/static/css/list.css" />
		<link rel="stylesheet" type="text/css" media="screen" href="{$staticHost}/static/css/page.css?v=1" />
		<script src="{$staticHost}/static/js/jquery-1.8.3.min.js"></script>
		<script src="{$staticHost}/static/js/js.js"></script>
		<script src="{$staticHost}/static/js/mod.js"></script>
	</head>
	<body>
		<section id="empty" class="empty-box">
			<div>
				<img src="{$staticHost}/static/images/bg/image2_03-min.png" >
				<p id="error"></p>
			</div>
		</section>
		<section id="con-box"></section>
		<script id="test" type="text/html">
		<% if(result.orderInfo.pay_status ==30){%>
			<div class="bg_skyblue ac f14 color-blue bold p10">
				退款中
  
			</div>
		<%}%>
		<% if(result.orderInfo.pay_status ==40){%>
			<div class="bg_skyblue ac f14 color-blue bold p10">
				已退款至原账户
				<p class="f14 pt10">请至支付宝中查看退款详情</p>
			</div>
		<%}%>
		<% if(result.orderInfo.status==3){%>
			<div class="bg_skyblue ac f14 color-blue bold p10">
				订单已取消
			</div>
		<%}%>

		<!-- 订单取消 -->

		<% if(result.orderInfo.status!=3){%>
		<div class="dns <%=result.orderInfo.dns%>">
			<% if(result.orderInfo.goodsList.length>0){%>
			<div class="ysp">
				<% if(result.orderInfo.pay_status==10){%>
				<div class="bg_skyblue ac f14 color-blue bold p10">待付款</div>
				<%}%>
				<% if(result.orderInfo.pay_status==20){%>
					<div class="bg_skyblue ac f14 color-blue bold p10">已付款</div>
				<%}%>

			</div>
			<%}%>
			<!-- 有商品 -->
			<% if(result.orderInfo.goodsList.length==0){%>
			<div>
				<% if(result.orderInfo.pay_status==10){%>
				<div class="bg_skyblue ac f14 color-blue bold p10">待付款</div>
				<%}%>
				<% if(result.orderInfo.pay_status==20){%>
					<div class="bg_skyblue ac f14 color-blue bold p10">已完成</div>
				<%}%>
			</div>
			<%}%>
			<!-- 无商品 付费活动 -->
		<%}%>
		</div>
		<!-- 未开始 -->

		<div class="start <%=result.orderInfo.start%>">
			
			<!-- <div class="ysp">
				<% if(result.orderInfo.pay_status==10){%>
				<div class="bg_skyblue ac f14 color-blue bold p10">订单已关闭</div>
				<%}%>
				活动开始未付款
			</div> -->
			
			<!-- 活动开始后订单未付款 -->

			<% if(result.orderInfo.goodsList.length==0){%>
			<div class="ysp">
				<% if(result.orderInfo.pay_status==20&&result.orderInfo.status==4){%>
				<div class="bg_skyblue ac f14 color-blue bold p10">已完成</div>
				<%}%>
			</div>
			<%}%>
			<!-- 活动开始后无商品订单已付款 -->
			<% if(result.orderInfo.goodsList.length>0){%>
			<div class="ysp">
				<% if(result.orderInfo.pay_status==20&&result.orderInfo.pay_status==1){%>
				<div class="bg_skyblue ac f14 color-blue bold p10">等待发货</div>
				<%}%>
			</div>
			<%}%>
			<!-- 活动开始后有商品订单已付款 -->
			<!-- 活动开始后订单已付款 -->
		</div>
		<!-- 已开始 -->


		<div class="over <%=result.orderInfo.over%>" >

			<div class="ysp">

				<% if(result.orderInfo.status==1&&result.orderInfo.pay_status==20){%>
				<div class="bg_skyblue ac f14 color-blue bold p10">等待发货</p>
				</div>
				<%}%>
				<!-- 等待发货 -->
				<% if(result.orderInfo.status==2&&result.orderInfo.pay_status==20){%>
				<div class="bg_skyblue ac f14 color-blue bold p10">已发货</div>
				<!-- 已发货 -->
				<%}%>
				<% if(result.orderInfo.pay_status==20&&result.orderInfo.status==4){%>
					<div class="bg_skyblue ac f14 color-blue bold p10">已完成</div>
				<%}%>
			<!-- 	<% if(result.orderInfo.pay_status==10){%>
				<div class="bg_skyblue ac f14 color-blue bold p10">订单已关闭</div>
				<%}%> -->

			</div>

		</div>
		<!-- 已结束 -->

		<!-- 判断活动状态 -->


		<div class="recipients line-gray-bottom">
			<%=result.orderInfo.name%> <span class="pl20"><%=result.orderInfo.phone%></span>
			<%if(result.orderInfo.goodsType==1){%>
			<p><%=result.orderInfo.address%></p>
			<%}%>
		</div>

			<!-- 收货详细信息 -->
			<div class="pr line-gray-bottom">
				<a href="{$staticHost}/show/logistics?num=<%=result.orderInfo.shipping_num%>&code=<%=result.orderInfo.shipping_code%>"></a>
				<ul class="wljs-list" style="padding-left:10px;">

				    <li>
				    	物流公司
				      	<span><%=result.orderInfo.shipping_name%></span>
				    </li>
					<li>
				      	快递单号
				      	<span><%=result.orderInfo.shipping_num%></span>
				    </li>
				    <!--  <li>
				      	联系电话
				      	<span>400-1233-5667</span>
				    </li> -->
				 </ul>
			 </div>
			 <!-- 物流单位  信息  记得增加js跳转   减少代码层次 -->
			 <p class="line-gray-bottom p10 f14">
				报名费
				<span class="color-blue fr">￥<%=result.orderInfo.cost%></span>
			</p>
			<%if(result.orderInfo.goodsList.length>0){%>
			<ul class="line-gray-bottom order-xq">
				<%for(var i=0; i<result.orderInfo.goodsList.length; i++){%>
				<li class="square-img">
					<img src="<%=result.orderInfo.goodsList[i].product.imageList[0]%>" />
					<ol>
						<li>
							<%=result.orderInfo.goodsList[i].product.title%>
							<span class="color-blue">￥<%=result.orderInfo.goodsList[i].goodsInfo.saleprice%></span>
						</li>
						<li class="pt-10">
							<%=result.orderInfo.subTtitle%>
							<span>X<%=result.orderInfo.goodsList[i].goodsInfo.num%></span>
						</li>
					</ol>
				</li>
				<%}%>
			</ul>
			<%}%>
			<div class="p15 clearfix lh30 line-gray-bottom f16">
				<p>
					运费
					<span id="yf" class="fr">￥<%=result.orderInfo.shipping_fee%></span>
				</p>
				<p id="discount">
					纪念品折扣
					<span id="zc" class="fr"><%=result.orderInfo.discount%>折</span>
				</p>
				<p class="fr">合计：￥<em class="color-blue"><%=result.orderInfo.total_fee%></em></p>
			</div>
			<div class="p10 lh34 line-gray-bottom clearfix f16">
				<p>
					应付
					<span class="fr">
					<%if(result.orderInfo.price_desc.length>0){%>
						<%=result.orderInfo.price_desc%>
						=
						<%}%>
					<%=result.orderInfo.total_fee%>

					</span>
				</p>
				<p>实付 <span class="color-blue fr"> <%=result.orderInfo.total_fee%></span></p>
			</div>

			<div class="p10 lh30 f14 color_gray mb50">
				订单号码　<%=result.orderInfo.order_id%><br/>
				创建时间　<%=result.orderInfo.addtime%><br/>
				
				<% if(result.orderInfo.status==2){%>
					发货时间<%=result.orderInfo.order_id%><br/>
					完成时间<%=result.orderInfo.addtime%>
				<%}%>
			</div>
			<%if(result.orderInfo.pay_status==20&&result.orderInfo.status==2){%>
				<a id="qrsh" class="dow-app color-blue">
		            确认收货
		        </a>
	        <%}%>
	        <%if(result.orderInfo.pay_status==10&&result.orderInfo.status==1){%>
	        	<a class=" dow-app color-blue" style="background:#eb4f3f;border:none;<%=result.orderInfo.btn%>" href="{$staticHost}/show/orderPay?order_id={$order_id}">
	            付款
	        </a>
	         <%}%>
		</script>

		<div class="masklayer" style="display: none;">
			<section class="affirm">
				<p>是否确认收货</p>
				<a id="fou">否</a>
				<a id="shi">是</a>

			</section>
		</div>
	</body>
	<script>

		var order_id = "{$order_id}";
		$(function(){
			$.getJSON('{$staticHost}/orderWeb/orderDetail',{"order_id":order_id}, function(data, error) {
				if(data.error){
					$("#empty").show()
					$("#empty p").html("订单空空，快去创建订单吧")

					setTimeout(function(){
            			window.history.back(-1);
            			
					},3000);
					return
				}
				var info=formatActivityData(data.result.orderInfo)
				var d = new Date(parseInt(info.stime) * 1000);
				info.stime =d.getFullYear()+"."+xs(d.getMonth()+1)+"."+xs(d.getDate())+ " "+xs( d.getHours())+":"+xs(d.getMinutes());
				// 赛事开始时间
				var q = new Date(parseInt(info.etime) * 1000);
				info.etime =q.getFullYear()+"."+xs(q.getMonth()+1)+"."+xs(q.getDate())+ " "+xs(d.getHours())+":"+xs(d.getMinutes());
				// 赛事结束时间
				var p = new Date(parseInt(info.expireTime) * 1000);
				info.expireTime =xs(p.getMonth()+1)+"."+xs(p.getDate())+ " "+xs(p.getHours())+":"+xs(p.getMinutes());
				// 订单过期时间
				function xs(n){ return n<10?("0"+n):n;}
				
				
				
				var html = template('test', data);
				document.getElementById('con-box').innerHTML = html;

				if(data.result.orderInfo.shipping_fee==0.00){
					$("#yf").html("包邮")
				}
				// 判断有无运费
				var discount = data.result.orderInfo.discount;
				if(discount>=1){
					$("#zc").html("无折扣")
				}else{
					discount = discount*10
					$("#zc").html(discount)
				}
				var commodityFor= data.result.orderInfo.goodsList;
				if(commodityFor.length ==0){
					$('#discount').hide();
				}else if(commodityFor.length==1){
					if(commodityFor[0].product){
						$('#discount').hide();
					}
					
				}

				if(data.result.orderInfo.shipping_num.length==0){
					$(".wljs-list span").html("_ _")
				}
				$("#fou").click(function(){
					$(".masklayer").hide();
					$("#qrsh").show();
				})
				$("#qrsh").click(function(){
					$(".masklayer").show();
					$("#qrsh").hide();

				})
				$("#shi").click(function(){
					var param = {"order_id":order_id}
					$.post("/orderWeb/finishOrder",param,
				    function(data,status){
				      data = JSON.parse(data)
				      location.reload() 
				      $("#qrsh").hide();
				      $(".masklayer").hide();
				    });
				})
				// 确认收货
			})
		// 	/***加载数据***/
	});
	
	function formatActivityData(info) {
		if(info) {
			
			var timestamp = Date.parse(new Date()).toString();
			 timestamp = timestamp.substr(0,10)
			if(info.stime > timestamp){
				
				info.dns='db';
				info.start='dn';
				info.over='dn';
				info.btn ='display:block';  //付款按钮是否显示  活动开始前显示
			}else if(timestamp > info.stime && timestamp < info.etime){
				
				info.dns='dn';
				info.start='db';
				info.over='dn';
				info.btn ='display:none';
			}else if(info.etime < timestamp){
				info.dns='dn';
				info.start='dn';
				info.over='db';
				info.btn ='display:none';
				
			}
			if(info.expireTime<timestamp){
				info.btn ='display:none';
			}
			
		return info;
		}
	}
	/***判断订单状态***/
	
	
	</script>
{template 'show/web-footer'}
